<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
  <title>c:choose 标签实例</title>
  <script src="${pageContext.request.contextPath}/webjars/jquery/3.7.1/jquery.min.js"></script>
  <script src="${pageContext.request.contextPath}/webjars/bootstrap/5.1.3/js/bootstrap.bundle.min.js"></script>
  <link rel="stylesheet" href="${pageContext.request.contextPath}/webjars/bootstrap/5.1.3/css/bootstrap.min.css"/>
</head>
<body>
<c:set var="salary" scope="session" value="${-2000*2}"/>
<p>你的工资为 : <c:out value="${salary}"/></p>
<c:choose>
  <c:when test="${salary <= 0}">
    太惨了。
  </c:when>
  <c:when test="${salary > 1000}">
    不错的薪水，还能生活。
  </c:when>
  <c:otherwise>
    什么都没有。
  </c:otherwise>
</c:choose>
<hr>
<div class="container mt-3">
  <h4>会员等级权益</h4>
  <form action="c_choose.jsp" method="post">
    <select class="form-select" aria-label="Default select example" name="level">
      <option selected>请选择会员等级</option>
      <option value="normal">普通用户</option>
      <option value="silver">银卡会员</option>
      <option value="gold">金卡会员</option>
      <option value="diamond">钻石会员</option>
      <option value="platinum">（测试无效值）白金会员</option>
    </select>
    <button type="submit"  class="btn btn-primary mt-3">查看权益</button>
  </form>
</div>
<hr>
<c:choose>
  <c:when test="${param.level == 'normal'}">
      <p>普通用户</p>
  </c:when>
  <c:when test="${param.level == 'silver'}">
    <p>银卡会员</p>
  </c:when>
  <c:when test="${param.level == 'gold'}">
    <p>金卡会员</p>
  </c:when>
  <c:when test="${param.level == 'diamond'}">
    <p>钻石会员</p>
  </c:when>
  <c:when test="${param.level == 'platinum'}">
    <p>白金会员</p>
  </c:when>
  <c:otherwise>
    <p>请选择会员等级</p>
  </c:otherwise>
</c:choose>

</body>
</html>
